<template>
  <div id="app">
    <ft-button>测试</ft-button>
    <ft-card
      imgSrc="a.jpg"
      :width="500"
      :imgHeight="300"
      summary="vue框架"
    ></ft-card>
    <br>
    <ft-card imgSrc="b.jpg" summary="vue框架">
      <template v-slot:footer>
        <p>三大框架之一</p>
      </template>
    </ft-card>
    <br>
    <ft-card imgSrc="c.jpg">
      react学习大法
      <template v-slot:footer>
        <p>三大框架之一</p>
      </template>
    </ft-card>
    <ft-infinite-list
      @load="load"
      :list-item="listItem"
      :spinner="loadSpinner"
      :container-height="containerHeight"
      :item-height="itemHeight"
      :items="items"
      :loading="loading"
    >
    </ft-infinite-list>
  </div>
</template>

<script>
const ListItem = {
  props: {
    data: {
      type: Object
    },
    itemExtra: {}
  },
  render() {
    return (
      <div class="list-item">
        <div class="index">{'list item ' + this.data.id}</div>
      </div>
    );
  }
};
export default {
  name: 'App',
  data() {
    return {
      items: [],
      listItem: ListItem,
      containerHeight: 300,
      itemHeight: 50,
      loading: false,
      lazyItems: [],
      loadSpinner: ''
    };
  },
  created() {
    this.load();
    let base = 1;
    for (let i = 0; i < 200; ++i) {
      this.items.push({ id: base++ });
    }
  },
  methods: {
    load() {
      console.log('load');
      // const me = this
      // this.loading = true

      // setTimeout(function () {
      //   for (let i = 0; i < 200; ++i) {
      //     me.items.push({ id: base++ })
      //   }
      //   me.loading = false
      // }, 200)
    }
  }
};
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.list-item {
  box-sizing: border-box;
  height: 50px;
  line-height: 50px;
  text-align: center;
  padding-bottom: 10px;
  border-bottom: 1px solid #ddd;
}
.list-item .index {
  text-align: center;
}
</style>
